/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package com.gitee.minimalismstyle.fresh.sys.api.service

import com.alicp.jetcache.anno.Cached
import com.gitee.minimalismstyle.fresh.common.api.annotation.ControllerFeignClient
import com.gitee.minimalismstyle.fresh.common.core.const.CacheConst
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.common.data.commons.service.LongModelBaseService
import com.gitee.minimalismstyle.fresh.sys.api.model.SysKeyValue
import com.gitee.minimalismstyle.fresh.sys.api.config.SysApiConst
import com.gitee.minimalismstyle.fresh.sys.api.model.SysKeyValues
import io.swagger.annotations.Api
import org.springframework.web.bind.annotation.*

/**
 * 字典业务接口
 * @author maochao
*/
@Api(value = "sysKeyValue", tags = ["字典业务接口"])
@ControllerFeignClient(serviceId = SysApiConst.SERVICE_ID, ctx =SysApiConst.CTX, path = "/sysKeyValue")
interface SysKeyValueService: LongModelBaseService<SysKeyValue>{

    @GetMapping("findByParentId/{parentId}")
    fun findByParentId(@PathVariable parentId: Long): R<List<SysKeyValue>>

    @GetMapping("findByParentKeyPath")
    fun findByParentKeyPath(parentKeyPath: String): R<List<SysKeyValue>>

    @GetMapping("findByKeyPath")
    fun findByKeyPath(keyPath: String): R<SysKeyValue>

    @Cached(name="sysKeyValuesCache-", key="#keyPath", expire = CacheConst.CACHE_DEFAULT_EXPIRE)
    @GetMapping("findSysKeyValuesByKeyPath")
    fun findSysKeyValuesByKeyPath(keyPath: String): R<SysKeyValues>

    @PutMapping("saveSysKeyValues")
    fun saveSysKeyValues(@RequestBody sysKeyValues: SysKeyValues): R<SysKeyValues>

    @DeleteMapping("deleteSysKeyValuesById/{id}")
    fun deleteSysKeyValuesById(@PathVariable id: Long): R<Int>
}